import { ILoadMapTypeAll } from '@/common';
import { getSelectDataCommon, getTenantID, getLoadMapList } from '@/utils';

export const DictionaryService = () => {
  const loadMdicIds: string[] = [
    `${getTenantID()}${ILoadMapTypeAll.MATERIEL_STATUS}`,
    `${getTenantID()}${ILoadMapTypeAll.ASSET_TYPE}`,
    `${getTenantID()}${ILoadMapTypeAll.ASSET_SOURCE_TYPE}`,
    `${getTenantID()}${ILoadMapTypeAll.ASSET_BRAND_TYPE}`,
  ];

  const { loadMapInfo: dictionaryData, mapLoading } = getLoadMapList(loadMdicIds);

  // 材料状态
  const materlelStatusList = getSelectDataCommon(dictionaryData?.[`${getTenantID()}${ILoadMapTypeAll.MATERIEL_STATUS}`], 'name', 'id');

  // 材料类型
  const assetTypeList = getSelectDataCommon(dictionaryData?.[`${getTenantID()}${ILoadMapTypeAll.ASSET_STATUS}`], 'name', 'id');
  // 材料来源
  const assetSourceType = getSelectDataCommon(dictionaryData?.[`${getTenantID()}${ILoadMapTypeAll.ASSET_SOURCE_TYPE}`], 'name', 'id');
  // 材料类型
  const assetBrandType = getSelectDataCommon(dictionaryData?.[`${getTenantID()}${ILoadMapTypeAll.ASSET_BRAND_TYPE}`], 'name', 'id');

  return {
    loadMdicIds,
    materlelStatusList,
    assetTypeList,
    assetSourceType,
    assetBrandType,
    mapLoading,
  };
};
